<template>
	<view class="pt30">
		<!-- <mg-input @tab="xzsj" hw='200' ht="营业时间" htc='f30' icn='t-r' isr='1' :value='params.time' dis='1' /> -->
		<view class="bf">
			<radio-group @change="radioChange" v-model="radioVal">
				<label v-for="(v, i) in arr" :key="i">
					<mg-cell isr="1" :btt="v.name" cname="p253" last="1">
						<view slot="hd" class="f-y-c mr30">
							<radio :value="v.value" :checked="v.value == radioVal" class="weui-check" />
							<text class="iconfont f40" :class="v.value == radioVal ? 'icondxz' : 'iconwgx'" :style="{ color: v.value == radioVal ? tColor : '' }"></text>
						</view>
					</mg-cell>
					<view class="p033">
						<view class="yg1db bs10">
							<view class="f32">{{ v.t }}</view>
							<view class="f24 c8 mt10">{{ v.t2 }}</view>
						</view>
					</view>
				</label>
			</radio-group>
		</view>
		<mg-load v-show="showloading" type="2"></mg-load>
	</view>
</template>

<script>
import { mapState } from 'vuex';
import mgInput from '@/components/form/mg-input.vue';
import mgRadio from '@/components/form/mg-radio.vue';
export default {
	name: 'yyxg',
	components: {
		mgInput,
		mgRadio
	},
	data() {
		return {
			showloading: false,
			params: {
				time: '00-2400'
			},
			arr: [
				{
					value: '1',
					name: '正常营业',
					t: '恢复营业',
					t2: '按营业时间自动开关店'
				},
				{
					value: '2',
					name: '暂停营业',
					t: '紧急关店',
					t2: '严重影响客户体验，请谨慎操作'
				}
			]
		};
	},
	computed: {
		...mapState(['sjxx']),
		radioVal() {
			return this.sjxx ? this.sjxx.storeOpen == 3 ? 2 : 1 : 2;
		}
	},
	onLoad(options) {
		this.util.setNT('营业状态修改');
	},
	methods: {
		async radioChange(e) {
			this.showloading = true;
			try {
				let res = await this.util.request({
					url: this.api.xgmdzt,
					method: 'POST',
					data: {
						type: 1,
						storeOpen: e.detail.value
					}
				});
				if (res) {
					this.util.message('操作成功', 3);
					uni.$emit('getbusiinfo');
				}
			} catch (e) {}
			this.showloading = false;
		}
	}
};
</script>
<style scoped lang="scss">
.yg1db {
	background: #f5f7fa;
	padding: 30rpx;
}
</style>
